package com.jiawei.mapper;

import com.jiawei.entity.database.Prem;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @author : willian fu
 * @date : 2019/12/11
 */
public interface PremMapper extends Mapper<Prem> {

    /**
     * 根据userId查询所拥有的权限
     * @param userId 用户id
     * @return 权限列表
     */
    @Select("SELECT prem.mark FROM user_role AS ur  " +
            "LEFT JOIN role_prem AS rp ON ur.role_id = rp.role_id " +
            "LEFT JOIN prem ON rp.prem_id = prem.id " +
            "WHERE ur.user_id = #{userId}")
    List<String> getPermByUser(@Param("userId") Long userId);

}
